package com.personal.system.mapper.content;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.personal.system.entity.content.Collect;
import com.personal.system.entity.vo.ApiArticleListVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 博客收藏表 Mapper 接口
 */
public interface CollectMapper extends BaseMapper<Collect> {

    /**
     * 我的收藏列表
     */
    @Select("select c.create_time,a.*,u.username as username,u.head_url as userAvatar, b.NAME AS categoryName,\n" +
            "               b.id AS categoryId from b_collect c\n" +
            "            left join b_article a on c.article_id = a.id\n" +
            "            left JOIN b_category b ON a.category_id = b.id\n" +
            "            left join sys_user u on a.user_id = u.id\n" +
            "        where c.user_id = #{userId} order by c.create_time desc")
    Page<ApiArticleListVO> selectCollectList(Page<ApiArticleListVO> tPage, @Param("userId") String userId);
}